/**
 * Created by easezhi on 2015/3/10.
 */
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var settings = require('../config');
mongoose.connect(settings.db_url);

var WcpaySchema = new Schema({
    appid:String,//服务号appid
    version:String,//微信支付版本号

    //v2参数
    partnerid:String,//财付通商户号
    partnerkey:String,//
    paysignkey:String,//支付签名专用key

    //v3参数
    mchid:String,//微信支付分配的商户号
    key:Stirng//商户支付密钥
})
var WcPayModel = mongoose.model('payconfig', WcpaySchema);
exports.PayConfig = WcPayModel;

//通过公众号appid查询该公众号支付参数
WcPayModel.findByAppid = function(option, callback){
    WcPayModel.findOne({appid:option.appid}, function(err, config){
        callback(err, config);
    })
}